﻿@using myTutor.Models
@model Article

@{
    ViewBag.Title = Model.Title;
    ViewBag.ShowMain = true;
    ViewBag.ShowSubFooter = true;
    ViewBag.AdsZoneKey = "ContentPage";
}
@if (Request.IsAuthenticated && UserMaster.IsInRole(User.Identity.Name, "1"))
{
    <span style="float:right; color:Red;">
        @Html.ActionLink("Chỉnh sửa", "ManageArticle", "Admin", new { artId = Model.Id, function = "edit", statusId = Model.GetStatusCode, positionId = Model.ArticleCategoryId }, null) | 
        @Html.ActionLink("Ngừng đăng", "ConfirmManage", "Shared", new { actionUrl = "~/Admin/ManageArticle?artId=" + Model.Id + "&function=lock&statusId=" + Model.GetStatusCode + "&positionId=" + Model.ArticleCategoryId, cancelUrl = "~/Article/Detail/" + Model.Id + "?index=" + ViewBag.Index, message = "Bạn có thật sự muốn ngừng đăng bài viết này không?" }, null) | 
        @Html.ActionLink("Xóa", "ConfirmManage", "Shared", new { actionUrl = "~/Admin/ManageArticle?artId=" + Model.Id + "&function=delete&statusId=" + Model.GetStatusCode + "&positionId=" + Model.ArticleCategoryId, cancelUrl = "~/Article/Detail/" + Model.Id + "?index=" + ViewBag.Index, message = "Bạn có thật sự muốn xóa bài viết này không?" }, null)
    </span>
}
<h2 style="clear:both;">@Model.Title</h2>
<div style = "margin-left:5%;margin-right:5%;text-align: justify;">
    <div style="font-size:11px;font-style:italic;">
        @Model.UpdatedTime 
    </div>
    <div style="float:left;margin-bottom:10px; margin-top:5px; font-weight:bold; color:#5F5F5F">
        @Model.PostIntro
    </div>
    @if (!string.IsNullOrEmpty(Model.ImageFileName))
    { 
        <div style="margin-bottom:10px;clear:both" align="center">            
            <img src="~/Files/Articles/@Model.ImageFileName" alt="" width="648px"/>
        </div>
    } 
    <div style="clear:both">
        @MvcHtmlString.Create(Model.Content)
    </div>
    <div style="padding-top:20px;">Chia sẽ bài viết này: 
        <span class='st_sharethis_large' displayText='ShareThis'></span>
        <span class='st_facebook_large' displayText='Facebook'></span>
        <span class='st_twitter_large' displayText='Tweet'></span>
        <span class='st_linkedin_large' displayText='LinkedIn'></span>
        <span class='st_googleplus_large' displayText='Google +'></span>
        <span class='st_blogger_large' displayText='Blogger'></span>
        <span class='st_email_large' displayText='Email'></span>
        <span class='st_plusone_large' displayText='Google +1'></span>
        <span class='st_fblike_large' displayText='Facebook Like'></span>
    </div>
    @if (ViewBag.Index!=null)
    {
    <p style="padding-top:10px;">
        @{
        List<SimpleObject> relativeArticals = ArticleCategory.GetSimpleRelativeArts(ViewBag.CategoryId, ViewBag.Index);
        int firstIndex = ViewBag.Index - relativeArticals.FindIndex(delegate(SimpleObject x) { return x.Id == Model.Id; });
         }
         @if (relativeArticals.Count > 1)
         {
             <h3>Các tin trong cùng khoảng thời gian</h3>   
             <ul>     
             @for (int i = 0; i < relativeArticals.Count; i++)
             {
                 if (relativeArticals[i].Id != Model.Id)
                 {
                        <li style="padding:5px;">
                            @Html.ActionLink(relativeArticals[i].StringValue, "Detail", "Article", new { id = relativeArticals[i].Id, index = (firstIndex++) }, null)
                        </li>
                 }
             }
             </ul>
             @Html.ActionLink("Quay về trang tin tức...","Index","Article")
         }
    </p>
    }
</div>
@section scripts
{
    <script type="text/javascript">var switchTo5x = true;</script>
    <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
    <script type="text/javascript">stLight.options({ publisher: "7ca7f06d-7639-4b97-a066-40a655f886d9" });</script>
}